import React, { memo, useEffect } from 'react';

import { renderRoutes } from 'react-router-config';
import { dicoverMenu } from '../../common/local-data.js';
import { NavLink } from 'react-router-dom';
import request from '../../services/request'

import {
  DiscoverWrapper,
  TopMenu
} from './style';

const HKDiscover = memo((props) => {
  const { route } = props;

  useEffect(() => {
    // console.log("HKDiscover 加载了")
    // request({
    //   url: "/banner"
    // }).then(res =>{
    //   console.log(res)
    // })

    // console.log(11)
    // const array1 = [1, 2, 3, 4];
    // const sumWithInitial = array1.reduce((previousValue, currentValue, currentIndex, array) => {
    //   console.log(previousValue, currentValue, currentIndex, array)
    //   return previousValue + currentValue
    // }, 10)
    // console.log("sumWithInitial:",sumWithInitial)
  }, [])

  return (
    <DiscoverWrapper>
      <div className='top'>
        <TopMenu className='wrap-v1'>
          {
            dicoverMenu.map((item, index) => {
              return (
                <div className="item" key={item.title}>
                  <NavLink to={item.link}>{item.title}</NavLink>
                </div>
              )
            })
          }
        </TopMenu>
      </div>

      {renderRoutes(route.routes)}
    </DiscoverWrapper>
  )
})

export default HKDiscover